{% extends 'generic/Popup.twig' %}
{% block popup_id %}edit-user-form{% endblock %}
{% block title %}
	<div id="edit-grader-modal-title">Edit Grader</div>
	<div id="new-grader-modal-title">New Grader</div>
	<div id="edit-student-modal-title">Edit Student</div>
	<div id="new-student-modal-title">New Student</div>
{% endblock %}
{% block body %}
    <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
    <input type="hidden" name="edit_user" value="false" />
    <div id="edit-user-form">
		<label for="user-form-already-exists-error-message" class="red-message full-width">
			<p id="user-form-already-exists-error-message">
				User is already in this course. Click to edit:
				<td>
					<a id="redirect-link-icon" onclick="redirectToEdit();" aria-label="edit entered user">
						<i class="fas fa-pencil-alt"></i>
					</a>
				</td>
			</p>
		</label>
		<label for="user_id">
            User ID:
            <input class="readonly" type="text" name="user_id" id="user_id" readonly="readonly" placeholder="(Required)" autocomplete="off"/>
        </label>
        <label for="user_numeric_id">
            User Numeric ID:
            <input type="text" name="user_numeric_id" id="user_numeric_id" placeholder="Digits Only (Optional)" />
        </label>
        <label for="user_firstname">
            Legal First Name:
            <input type="text" name="user_firstname" id="user_firstname" placeholder="(Required)" />
        </label>
        <label for="user_preferred_firstname">
            Preferred First Name:
            <input type="text" name="user_preferred_firstname" id="user_preferred_firstname" placeholder="(Optional)" />
        </label>
        <label for="user_lastname">
            Legal Last Name:
            <input type="text" name="user_lastname" id="user_lastname" placeholder="(Required)" />
        </label>
        <label for="user_preferred_lastname">
            Preferred Last Name:
            <input type="text" name="user_preferred_lastname" id="user_preferred_lastname" placeholder="(Optional)" />
        </label>
        <label for="user_email">
            Email:
            <input type="text" name="user_email" id="user_email" placeholder="(Optional)" />
        </label>
        {% if use_database %}
            <label>
                Password:
                <input type="password" name="user_password" placeholder="New Password" />
            </label>
        {% endif %}
        <label for="registered_section" class="full-width">
            Registration Section:
            <select name="registered_section" id="registered_section">
                <option value="null">Not Registered</option>
                {% for section in reg_sections %}
                    <option value='{{ section.sections_registration_id }}'>Section {{ section.sections_registration_id }}</option>
                {% endfor %}
            </select>
        </label>
        <p id="user-form-student-error-message" class="red-message full-width">
            Warning: Students with no registration section cannot login to the course
        </p>
        <label for="rotating_section" class="full-width">
            Rotating Section:
            <select name="rotating_section" id="rotating_section">
                <option value="null">No Section</option>
                {% for section in rot_sections %}
                    <option value='{{ section.sections_rotating_id }}'>Section {{ section.sections_rotating_id }}</option>
                {% endfor %}
            </select>
        </label>
        <label for="manual_registration" class="full-width">
            <input type="checkbox" id="manual_registration" name="manual_registration">
            Manually Registered User (no automatic updates)
        </label>
        <label for="user_group" class="full-width">
            Group:
            <select name="user_group" id="user_group">
                <option value="1">Instructor</option>
                <option value="2">Full Access Grader (Grad TA)</option>
                <option value="3">Limited Access Grader (Mentor)</option>
                <option value="4">Student</option>
            </select>
        </label>
        <div id="user-form-assigned-sections" class="full-width" hidden>
            <h3>Assigned Registration Sections for Grading</h3>
            {% for section in reg_sections %}
                <label for="grs_{{ section.sections_registration_id }}">
                    <input type="checkbox" id="grs_{{ section.sections_registration_id }}" name="grading_registration_section[]" value="{{ section.sections_registration_id }}">
                    Section {{ section.sections_registration_id }}
                </label>
            {% endfor %}
        </div>
    </div>
{% endblock %}
{% block form %}
    <form method="post" action="{{ update_url }}" onchange="userFormChange()">
        {{ parent() }}
    </form>
{% endblock %}
{% block buttons %}
    <a onclick="closeButton()" class="btn btn-default close-button">Close</a>
    <input class="btn btn-primary" type="submit" value="Submit" id="user-form-submit" />
{% endblock %}
